//
//  JYTNameUpdateViewController.m
//  JYT_IOS
//
//  Created by nxa-chengjinhui on 2017/1/4.
//  Copyright © 2017年 nxa-yuanguoxiang. All rights reserved.
//

#import "JYTNameUpdateViewController.h"

@interface JYTNameUpdateViewController ()

@property (nonatomic,strong) UITextField *textfild;

@end

@implementation JYTNameUpdateViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    
    self.view.backgroundColor = [UIColor whiteColor];
    
    NSDictionary *dic = @{@"lftBtnBgImg":@"ic_goback",
                          @"lftBtnTitle":@"no",
                          @"pageTitle":@"修改昵称",
                          @"rhtBtnBgImg":@"no",
                          @"rhtBtnTitle":@"no"};
    
    [self setNavgationBarWithDic:dic];
   
    UILabel *nameLab = [[UILabel alloc] initWithFrame:CGRectMake(20, 64+20, 60, 40)];
    nameLab.text = @"昵称";
    nameLab.font = [UIFont systemFontOfSize:16];
    nameLab.adjustsFontSizeToFitWidth = YES;
    nameLab.textAlignment = NSTextAlignmentCenter;
    nameLab.backgroundColor = kColor(244, 244, 244);
    [self.view addSubview:nameLab];
    
    self.textfild = [[UITextField alloc] initWithFrame:CGRectMake(CGRectGetMaxX(nameLab.frame), 84,CURRENT_SCREEN_WIDTH-40-nameLab.frame.size.width, 40)];
    self.textfild.placeholder = @"请填写新昵称";
    self.textfild.backgroundColor = kColor(244, 244, 244);
    [self.view addSubview:self.textfild];
    
    UIView *blankView = [[UIView alloc] initWithFrame:CGRectMake(self.textfild.frame.origin.x,self.textfild.frame.origin.y,5, self.textfild.frame.size.height)];
    self.textfild.leftView = blankView;
    self.textfild.leftViewMode =UITextFieldViewModeAlways;  // 这里是用来设置leftView的实现时机的
    
    UIView *line2 = [[UIView alloc] initWithFrame:CGRectMake(CGRectGetMaxX(nameLab.frame), nameLab.frame.origin.y+7, 1.5, 24)];
    line2.backgroundColor = [UIColor grayColor];
    [self.view addSubview:line2];

    UIButton *comfireBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    comfireBtn.frame = CGRectMake(20, CGRectGetMaxY(self.textfild.frame)+20 ,CURRENT_SCREEN_WIDTH-40, 40);
    [comfireBtn setBackgroundColor:kColor(58, 150, 248)];
    [comfireBtn setTitle:@"确定" forState:UIControlStateNormal];
    comfireBtn.layer.masksToBounds = YES;
    comfireBtn.layer.cornerRadius = 5;
    [comfireBtn addTarget:self action:@selector(comfireBtnClicked) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:comfireBtn];
}

-(void)comfireBtnClicked{
    
    
    
    [[JYTUserManager shared] setNikeName:self.textfild.text];
}

-(void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event{
    [self.textfild resignFirstResponder];
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
